package tazmania.entity;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;

import tazadum.engine.Entity;
import tazadum.engine.Interval;
import tazadum.engine.Signal;

public class SolidBackgroundEntity implements Entity {
	private final Signal signal;

	public SolidBackgroundEntity(Signal signal) {
		this.signal = signal;
	}

	@Override
	public void precalc(final GLAutoDrawable drawable, final float screenRatio) {
	}

	@Override
	public void update(final GLAutoDrawable drawable, final float globalTime, final float localTime, final float dt, final Interval interval) {
		final GL gl = drawable.getGL();
		
		final float R = signal.channel(Signal.CHANNEL_R);
		final float G = signal.channel(Signal.CHANNEL_G);
		final float B = signal.channel(Signal.CHANNEL_B);

		gl.glClearColor(R, G, B, 1.0f);
		gl.glDepthRangef(0.1f, 1000);
		gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
	}
	
	@Override
	public void destroy(final GLAutoDrawable drawable) {
	}	
}
